import store from '../../store'

export default {
  inserted (el, binding, vnode) {
    const { value } = binding
    const roles = store.state.rolePermArr
    let authValue = value[0]
    let opterFlag = value.length > 1 ? value[1] : ''
    const hasPermission = roles.indexOf(authValue) > -1

    if (!hasPermission) { // 无权限：则删除或禁用此按钮或a 标签
      if (opterFlag == '' || opterFlag == '0') { el.parentNode && el.parentNode.removeChild(el) } else { el.disabled = true }
    }
  }
}
